const {Sequelize, DataTypes} = require("sequelize");
const start = require("./utils/connect");

(async()=>{
  const sequelize = await start();
  const Post = sequelize.define("Post",{
    name:{
      type:DataTypes.STRING,
      allowNull:false
    },
    uuid:{
      type:DataTypes.UUID,
      defaultValue:Sequelize.UUID
    }
  },{
    paranoid:true,
    freezeTableName:true // 强制使用定义表名
  });

  


  await Post.sync({
    // force:true,
    alter:true
  });

  // await Post.create({name:"askwan"});
  // await Post.create({name:"post"});
  // await Post.create({name:"wuhao"});
  // await Post.create({name:"wangmengjiao"});

  // const posts = await Post.findAll();
  // console.log(posts.map(el=>el.toJSON()))
  // let current = posts[1];
  // console.log("current",current.destroy);

  const askwan = await Post.findOne({
    where:{
      name:"askwan2"
    }
  });

  askwan.update({name:"askwan6"});

  console.log(askwan.toJSON());

  // await current.destroy();

  

  
})()